cmd: Drop "ostree admin install" and curl fetcher
authorColin Walters <walters@verbum.org>
Wed, 10 Jul 2013 00:16:49 +0000 (20:16 -0400)
committerColin Walters <walters@verbum.org>
Wed, 10 Jul 2013 00:18:29 +0000 (20:18 -0400)
It isn't useful at the moment, since the deploy stuff all changed.  It
will make sense to bring back later, but for now let's not carry
broken untested code.

Makefile-ostree.am
src/ostree/ostree-curl-fetcher.c [deleted file]
src/ostree/ostree-curl-fetcher.h [deleted file]
src/ostree/ot-admin-builtin-install.c [deleted file]
src/ostree/ot-builtin-admin.c

index b4382356a61fcf30467844ea19dbafb4210998fa..44cc58818dad0d6dd824a1c1d806c3b6b4baa098 100644 (file)
@@ -20,8 +20,6 @@
 bin_PROGRAMS += ostree
 
 ostree_SOURCES = src/ostree/main.c \
-       src/ostree/ostree-curl-fetcher.h \
-       src/ostree/ostree-curl-fetcher.c \
        src/ostree/ot-builtin-admin.c \
        src/ostree/ot-builtins.h \
        src/ostree/ot-builtin-cat.c \
@@ -53,7 +51,6 @@ ostree_SOURCES += \
        src/ostree/ot-admin-builtin-deploy.c \
        src/ostree/ot-admin-builtin-prune.c \
        src/ostree/ot-admin-builtin-os-init.c \
-       src/ostree/ot-admin-builtin-install.c \
        src/ostree/ot-admin-builtin-status.c \
        src/ostree/ot-admin-builtin-upgrade.c \
        src/ostree/ot-admin-builtins.h \
diff --git a/src/ostree/ostree-curl-fetcher.c b/src/ostree/ostree-curl-fetcher.c
deleted file mode 100644 (file)
index fbe96ab..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
- *
- * Copyright (C) 2011,2012 Colin Walters <walters@verbum.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Colin Walters <walters@verbum.org>
- */
-
-#include "config.h"
-
-#include "ostree-curl-fetcher.h"
-#include "ostree.h"
-
-struct OstreeCurlFetcher
-{
-  GObject parent_instance;
-
-  GFile *tmpdir;
-  
-  GSSubprocess *curl_proc;
-  GQueue *queue;
-};
-
-G_DEFINE_TYPE (OstreeCurlFetcher, ostree_curl_fetcher, G_TYPE_OBJECT)
-
-static void
-ostree_curl_fetcher_finalize (GObject *object)
-{
-  OstreeCurlFetcher *self;
-
-  self = OSTREE_CURL_FETCHER (object);
-
-  g_clear_object (&self->curl_proc);
-  g_queue_free (self->queue);
-
-  G_OBJECT_CLASS (ostree_curl_fetcher_parent_class)->finalize (object);
-}
-
-static void
-ostree_curl_fetcher_class_init (OstreeCurlFetcherClass *klass)
-{
-  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
-  gobject_class->finalize = ostree_curl_fetcher_finalize;
-}
-
-static void
-ostree_curl_fetcher_init (OstreeCurlFetcher *self)
-{
-  self->queue = g_queue_new ();
-}
-
-OstreeCurlFetcher *
-ostree_curl_fetcher_new (GFile *tmpdir)
-{
-  OstreeCurlFetcher *self = (OstreeCurlFetcher*)g_object_new (OSTREE_TYPE_CURL_FETCHER, NULL);
-
-  self->tmpdir = g_object_ref (tmpdir);
-  return self;
-}
-
-typedef struct {
-  OstreeCurlFetcher *self;
-  gchar *uri;
-  GFile *tmpfile;
-  GCancellable *cancellable;
-  GSimpleAsyncResult *result;
-} OstreeCurlFetcherOp;
-
-static void
-fetcher_op_free (OstreeCurlFetcherOp *op)
-{
-  g_clear_object (&op->self);
-  g_free (op->uri);
-  g_clear_object (&op->tmpfile);
-  g_clear_object (&op->cancellable);
-  g_free (op);
-}
-
-static void
-maybe_fetch (OstreeCurlFetcher     *self);
-
-static void
-on_curl_exited (GObject       *object,
-                GAsyncResult  *result,
-                gpointer       user_data)
-{
-  GSSubprocess *proc = GS_SUBPROCESS (object);
-  OstreeCurlFetcherOp *op = user_data;
-  GError *error = NULL;
-  int estatus;
-  
-  if (!gs_subprocess_wait_finish (proc, result, &estatus, &error))
-    goto out;
-
-  if (!g_spawn_check_exit_status (estatus, &error))
-    goto out;
-
- out:
-  if (error)
-      g_simple_async_result_take_error (op->result, error);
-  
-  g_simple_async_result_complete (op->result);
-  
-  g_clear_object (&op->self->curl_proc);
-
-  maybe_fetch (op->self);
-
-  g_object_unref (op->result);
-}
-
-static void
-maybe_fetch (OstreeCurlFetcher     *self)
-{
-  OstreeCurlFetcherOp *op;
-  GError *error = NULL;
-  gs_unref_object GSSubprocessContext *context = NULL;
-
-  if (self->curl_proc != NULL
-      || g_queue_is_empty (self->queue))
-    return;
-
-  op = g_queue_pop_head (self->queue);
-
-  if (!ostree_create_temp_regular_file (self->tmpdir, NULL, NULL,
-                                        &op->tmpfile, NULL,
-                                        op->cancellable, &error))
-    goto out;
-
-  context = gs_subprocess_context_newv ("curl", op->uri, "-o",
-                                        gs_file_get_path_cached (op->tmpfile),
-                                        NULL);
-  g_assert (self->curl_proc == NULL);
-  self->curl_proc = gs_subprocess_new (context, op->cancellable, &error);
-  if (!self->curl_proc)
-    goto out;
-
-  gs_subprocess_wait (self->curl_proc, op->cancellable,
-                      on_curl_exited, op);
-
- out:
-  if (error)
-    {
-      g_simple_async_result_take_error (op->result, error);
-      g_simple_async_result_complete (op->result);
-    }
-}
-
-void
-ostree_curl_fetcher_request_uri_async (OstreeCurlFetcher          *self,
-                                       const char                 *uri,
-                                       GCancellable               *cancellable,
-                                       GAsyncReadyCallback         callback,
-                                       gpointer                    user_data)
-{
-  OstreeCurlFetcherOp *op;
-
-  op = g_new0 (OstreeCurlFetcherOp, 1);
-  op->self = g_object_ref (self);
-  op->uri = g_strdup (uri);
-  op->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
-  op->result = g_simple_async_result_new ((GObject*) self, callback, user_data,
-                                          ostree_curl_fetcher_request_uri_async);
-
-  g_queue_push_tail (self->queue, op);
-
-  g_simple_async_result_set_op_res_gpointer (op->result, op,
-                                             (GDestroyNotify) fetcher_op_free);
-  
-  maybe_fetch (self);
-}
-
-GFile *
-ostree_curl_fetcher_request_uri_finish (OstreeCurlFetcher     *self,
-                                        GAsyncResult          *result,
-                                        GError               **error)
-{
-  GSimpleAsyncResult *simple;
-  OstreeCurlFetcherOp *op;
-
-  g_return_val_if_fail (g_simple_async_result_is_valid (result, (GObject*)self, ostree_curl_fetcher_request_uri_async), FALSE);
-
-  simple = G_SIMPLE_ASYNC_RESULT (result);
-  if (g_simple_async_result_propagate_error (simple, error))
-    return NULL;
-  op = g_simple_async_result_get_op_res_gpointer (simple);
-
-  return g_object_ref (op->tmpfile);
-}
diff --git a/src/ostree/ostree-curl-fetcher.h b/src/ostree/ostree-curl-fetcher.h
deleted file mode 100644 (file)
index 2351ea6..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
- *
- * Copyright (C) 2012 Colin Walters <walters@verbum.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#pragma once
-
-#include <gio/gio.h>
-
-G_BEGIN_DECLS
-
-#define OSTREE_TYPE_CURL_FETCHER         (ostree_curl_fetcher_get_type ())
-#define OSTREE_CURL_FETCHER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), OSTREE_TYPE_CURL_FETCHER, OstreeCurlFetcher))
-#define OSTREE_CURL_FETCHER_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), OSTREE_TYPE_CURL_FETCHER, OstreeCurlFetcherClass))
-#define OSTREE_IS_CURL_FETCHER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), OSTREE_TYPE_CURL_FETCHER))
-#define OSTREE_IS_CURL_FETCHER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), OSTREE_TYPE_CURL_FETCHER))
-#define OSTREE_CURL_FETCHER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), OSTREE_TYPE_CURL_FETCHER, OstreeCurlFetcherClass))
-
-typedef struct OstreeCurlFetcherClass   OstreeCurlFetcherClass;
-typedef struct OstreeCurlFetcher        OstreeCurlFetcher;
-
-struct OstreeCurlFetcherClass
-{
-  GObjectClass parent_class;
-};
-
-GType   ostree_curl_fetcher_get_type (void) G_GNUC_CONST;
-
-OstreeCurlFetcher *ostree_curl_fetcher_new (GFile *tmpdir);
-
-void ostree_curl_fetcher_request_uri_async (OstreeCurlFetcher         *self,
-                                            const char                *uri,
-                                            GCancellable              *cancellable,
-                                            GAsyncReadyCallback        callback,
-                                            gpointer                   user_data);
-
-GFile *ostree_curl_fetcher_request_uri_finish (OstreeCurlFetcher         *self,
-                                               GAsyncResult          *result,
-                                               GError               **error);
-
-G_END_DECLS
-
diff --git a/src/ostree/ot-admin-builtin-install.c b/src/ostree/ot-admin-builtin-install.c
deleted file mode 100644 (file)
index 0d912b3..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
- *
- * Copyright (C) 2012 Colin Walters <walters@verbum.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Colin Walters <walters@verbum.org>
- */
-
-#include "config.h"
-
-#include "ot-admin-builtins.h"
-#include "ot-admin-functions.h"
-#include "ostree-curl-fetcher.h"
-#include "otutil.h"
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <glib/gi18n.h>
-
-typedef struct {
-  GMainLoop *loop;
-  GFile *osconfig_path;
-} OtAdminBuiltinInstall;
-
-static GOptionEntry options[] = {
-  { NULL }
-};
-
-static void
-on_keyfile_retrieved (GObject       *obj,
-                      GAsyncResult  *result,
-                      gpointer       user_data)
-{
-  OtAdminBuiltinInstall *self = user_data;
-  GError *error = NULL;
-  
-  self->osconfig_path = ostree_curl_fetcher_request_uri_finish ((OstreeCurlFetcher*)obj, result, &error);
-  if (!self->osconfig_path)
-    goto out;
-  
- out:
-  if (error)
-    {
-      g_printerr ("%s\n", error->message);
-      exit (1);
-    }
-  g_main_loop_quit (self->loop);
-}
-
-gboolean
-ot_admin_builtin_install (int argc, char **argv, OtAdminBuiltinOpts *admin_opts, GError **error)
-{
-  OtAdminBuiltinInstall self_data;
-  OtAdminBuiltinInstall *self = &self_data;
-  GOptionContext *context;
-  gboolean ret = FALSE;
-  const char *keyfile_arg = NULL;
-  const char *treename_arg = NULL;
-  gs_unref_object GFile *deploy_dir = NULL;
-  gs_unref_object GFile *osdir = NULL;
-  gs_unref_object GFile *dest_osconfig_path = NULL;
-  gs_unref_ptrarray GPtrArray *subproc_args = NULL;
-  gs_free char *osname = NULL;
-  gs_free char *repoarg = NULL;
-  gs_free char *ostree_dir_arg = NULL;
-  gs_free char *tree_to_deploy = NULL;
-  GKeyFile *keyfile = NULL;
-  __attribute__((unused)) GCancellable *cancellable = NULL;
-
-  memset (self, 0, sizeof (*self));
-
-  context = g_option_context_new ("KEYFILE [TREE] - Initialize, download, and deploy operating system");
-  g_option_context_add_main_entries (context, options, NULL);
-
-  if (!g_option_context_parse (context, &argc, &argv, error))
-    goto out;
-
-  if (argc < 2)
-    {
-      ot_util_usage_error (context, "KEYFILE must be specified", error);
-      goto out;
-    }
-
-  if (!ot_admin_ensure_initialized (admin_opts->sysroot, cancellable, error))
-    goto out;
-
-  self->loop = g_main_loop_new (NULL, TRUE);
-
-  keyfile_arg = argv[1];
-  if (argc > 2)
-    treename_arg = argv[2];
-
-  keyfile = g_key_file_new ();
-
-  if (g_str_has_prefix (keyfile_arg, "http://") || g_str_has_prefix (keyfile_arg, "https://"))
-    {
-      gs_unref_object GFile *tmp = g_file_new_for_path (g_get_tmp_dir ());
-      gs_unref_object OstreeCurlFetcher *fetcher = ostree_curl_fetcher_new (tmp);
-
-      g_print ("Fetching %s...\n", keyfile_arg);
-      ostree_curl_fetcher_request_uri_async (fetcher, keyfile_arg, cancellable,
-                                             on_keyfile_retrieved, self);
-
-      g_main_loop_run (self->loop);
-    }
-  else
-    {
-      self->osconfig_path = g_file_new_for_path (keyfile_arg);
-    }
-
-  if (!g_key_file_load_from_file (keyfile, gs_file_get_path_cached (self->osconfig_path), 0,
-                                  error))
-    goto out;
-
-  osname = g_key_file_get_string (keyfile, "os", "Name", error);
-
-  ostree_dir_arg = g_strconcat ("--sysroot=",
-                                gs_file_get_path_cached (admin_opts->sysroot),
-                                NULL);
-
-  if (!gs_subprocess_simple_run_sync (NULL,
-                                      GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
-                                      cancellable, error,
-                                      "ostree", "admin", ostree_dir_arg, "os-init", osname, NULL))
-    goto out;
-
-  if (treename_arg)
-    {
-      tree_to_deploy = g_strdup (treename_arg);
-    }
-  else
-    {
-      tree_to_deploy = g_key_file_get_string (keyfile, "os", "TreeDefault", error);
-      if (!tree_to_deploy)
-        goto out;
-    }
-
-  osdir = ot_gfile_get_child_build_path (admin_opts->sysroot, "ostree", "deploy", osname, NULL);
-  dest_osconfig_path = ot_gfile_get_child_strconcat (osdir, osname, ".cfg", NULL);
-
-  if (!g_file_copy (self->osconfig_path, dest_osconfig_path, G_FILE_COPY_OVERWRITE | G_FILE_COPY_TARGET_DEFAULT_PERMS,
-                    cancellable, NULL, NULL, error))
-    goto out;
-
-  if (!gs_file_unlink (self->osconfig_path, cancellable, error))
-    goto out;
-
-  repoarg = g_strconcat ("--repo=",
-                         gs_file_get_path_cached (admin_opts->sysroot), "/ostree/repo",
-                         NULL);
-
-  {
-    gs_free char *repourl = NULL;
-      
-    repourl = g_key_file_get_string (keyfile, "os", "Repo", error);
-    if (!repourl)
-      goto out;
-    
-    if (!gs_subprocess_simple_run_sync (NULL,
-                                        GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
-                                        cancellable, error,
-                                        "ostree", repoarg, "remote", "add",
-                                        osname, repourl, tree_to_deploy, NULL))
-      goto out;
-  }
-
-  if (!gs_subprocess_simple_run_sync (NULL,
-                                      GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
-                                      cancellable, error,
-                                        "ostree", "pull", repoarg, osname, NULL))
-    goto out;
-
-  if (!gs_subprocess_simple_run_sync (NULL,
-                                      GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
-                                      cancellable, error,
-                                      "ostree", "admin", ostree_dir_arg, "deploy", osname,
-                                      tree_to_deploy, NULL))
-    goto out;
-
-  ret = TRUE;
- out:
-  if (self->loop)
-    g_main_loop_unref (self->loop);
-  g_clear_object (&self->osconfig_path);
-  g_clear_pointer (&keyfile, (GDestroyNotify) g_key_file_unref);
-  if (context)
-    g_option_context_free (context);
-  return ret;
-}
index 8b54f8835aed87c33bd7b5951f354aabae49165b..929542da8f1dc771699bad5a2cb4b7417bc2b32f 100644 (file)
@@ -47,7 +47,6 @@ static OstreeAdminCommand admin_subcommands[] = {
   { "os-init", ot_admin_builtin_os_init },
   { "init-fs", ot_admin_builtin_init_fs },
   { "deploy", ot_admin_builtin_deploy },
-  { "install", ot_admin_builtin_install },
   { "upgrade", ot_admin_builtin_upgrade },
   { "prune", ot_admin_builtin_prune },
   { "status", ot_admin_builtin_status },